//系统管理
import request from '@/plugins/request';

export function addMenu (data) {
  return request({
      url: '/permission/menu/add',
      method: 'post',
      data
  });
}

// 根据父ID查询字典
export function getDictByParentId (data) {
  return request({
      url: '/user/pc/sys/dict/getDictByParentId',
      method: 'post',
      data
  });
}

// 根据父ID查询返回树结构
export function getDictTreeByParentId (data) {
  return request({
      url: '/global/base/getDictTreeByParentId',
      method: 'post',
      data
  });
}
// 修改字典
export function updateDict (data) {
  return request({
      url: '/user/pc/sys/dict/updateDict',
      method: 'post',
      data
  });
}
// 添加字典
export function addDict (data) {
  return request({
      url: '/user/pc/sys/dict/addDict',
      method: 'post',
      data
  });
}

// 获取短信模板分页
export function smsTemplateGetPage (data) {
  return request({
      url: '/user/pc/smsTemplate/getPage',
      method: 'post',
      data
  });
}
// 添加短信模板
export function smsTemplateAddData (data) {
  return request({
      url: '/user/pc/smsTemplate/addData',
      method: 'post',
      data
  });
}
// 编辑短信模板
export function smsTemplateEditData (data) {
  return request({
      url: '/user/pc/smsTemplate/editData',
      method: 'post',
      data
  });
}
// 删除短信模板
export function smsTemplateDelData (data) {
  return request({
      url: '/user/pc/smsTemplate/delData',
      method: 'post',
      data
  });
}


//获取菜单列表
export function getMenuTree(data = {}) {
  return request({
    url: "/user/pc/permission/menu/getTree",
    method: "post",
    data,
  });
}

// 绑定权限菜单
export function bindAuthMenu(data = {}) {
  return request({
    url: "/user/pc/permission/authority/bindAuthMenu",
    method: "post",
    data,
  });
}

// 获取角色组列表
export function getRoleList(data) {
  return request({
    url: "/user/pc/permission/role/list",
    method: "post",
    data,
  });
}

// 添加权限
export function addAuthority(data) {
  return request({
    url: "/user/pc/permission/authority/add",
    method: "post",
    data,
  });
}

// 编辑权限
export function updateAuthority(data) {
  return request({
    url: "/user/pc/permission/authority/update",
    method: "post",
    data,
  });
}

// 权限管理接口
// 组添加
export function createGroup(data) {
  return request({
    url: "/user/pc/permission/group/add",
    method: "post",
    data,
  });
}

// 组编辑
export function updateGroup(data) {
  return request({
    url: "/user/pc/permission/group/edit",
    method: "post",
    data,
  });
}

// 组删除
export function detaleGroup(data) {
  return request({
    url: "/user/pc/permission/group/del",
    method: "post",
    data,
  });
}

// 组详情
export function getGoupDetail(data) {
  return request({
    url: "/user/pc/permission/group/detail",
    method: "post",
    data,
  });
}

// 获取角色分组分页
export function getGoupList(data) {
  return request({
    url: "/user/pc/permission/group/list",
    method: "post",
    data,
  });
}

// 创建角色
export function addRole(data) {
  return request({
    url: "/user/pc/permission/role/add",
    method: "post",
    data,
  });
}

// 更新角色
export function updateRole(data) {
  return request({
    url: "/user/pc/permission/role/update",
    method: "post",
    data,
  });
}

// 删除角色
export function deleteRole(data) {
  return request({
    url: "/user/pc/permission/role/delByRoleId",
    method: "post",
    data,
  });
}

// 公司组织架构
// 获取公司与子公司的分级
export function getOrgTree(data) {
  return request({
    url: "/user/pc/org/getOrgTree",
    method: "post",
    data,
  });
}

// 获取公司与子公司list
export function getOrgList(data) {
  return request({
    url: "/user/pc/sys/org/getOrgList",
    method: "post",
    data,
  });
}

// 创建公司
export function addCompany(data) {
  return request({
    url: "/user/pc/sys/org/company/add",
    method: "post",
    data,
  });
}

// 编辑公司
export function updateCompany(data) {
  return request({
    url: "/user/pc/sys/org/company/update",
    method: "post",
    data,
  });
}

// 冻结公司
export function freezeCompany(data) {
  return request({
    url: "/user/pc/sys/org/company/freeze",
    method: "post",
    data,
  });
}

// 解冻公司
export function unFreezeCompany(data) {
  return request({
    url: "/user/pc/sys/org/company/unFreeze",
    method: "post",
    data,
  });
}

// 设置公司管理员
export function setCompanyAdmin(data) {
  return request({
    url: "/user/pc/sys/org/company/setCompanyAdmin",
    method: "post",
    data,
  });
}

// 根据公司部门获取部门下所有用户
export function getDepartmentAllUserList(data) {
  return request({
    url: "/user/pc/sys/org/department/getDepartmentAllUserList",
    method: "post",
    data,
  });
}

// 创建部门
export function addDepartment(data) {
  return request({
    url: "/user/pc/org/department/add",
    method: "post",
    data,
  });
}

// 修改部门
export function updateDepartment(data) {
  return request({
    url: "/user/pc/org/department/update",
    method: "post",
    data,
  });
}

// 删除部门
export function deleteDepartment(data) {
  return request({
    url: "/user/pc/org/department/del",
    method: "post",
    data,
  });
}

// 获取部门绑定的角色
export function getBindAuthList(data) {
  return request({
    url: "/user/pc/sys/org/department/getBindAuthList",
    method: "post",
    data,
  });
}

// 绑定部门和权限
export function bindDepartmentAuth(data) {
  return request({
    url: "/user/pc/sys/org/department/bindDepartmentAuth",
    method: "post",
    data,
  });
}

// 获取权限
export function authorityList(data) {
  return request({
    url: "/user/pc/permission/authority/list",
    method: "post",
    data,
  });
}

// 权限绑定菜单
export function bindMenuAuth(data) {
  return request({
    url: "/user/pc/permission/menu/bindMenuAuth",
    method: "post",
    data,
  });
}

// 编辑权限
// export function updateAuthority(data) {
//   return request({
//     url: "/user/pc/permission/authority/list",
//     method: "post",
//     data,
//   });
// }

// 角色绑定权限
export function bindRoleAuth(data) {
  return request({
    url: "/user/pc/permission/role/bindRoleAuth",
    method: "post",
    data,
  });
}


// 删除权限
export function delByAuthId(data) {
  return request({
    url: "/user/pc/permission/authority/delByAuthId",
    method: "post",
    data,
  });
}

// 设置用户为部门负责人
// export function setUserIsPrincipal(data) {
//   return request({
//     url: "/user/pc/sys/org/department/setUserIsPrincipal",
//     method: "post",
//     data,
//   });
// }

// 查询用户
export function getOrgAllUserPage(data) {
  return request({
    url: "/user/pc/sys/org/getOrgAllUserPage",
    method: "post",
    data,
  });
}

// 获取绑定菜单的权限
export function getBindAuthMenuDetail(data) {
  return request({
    url: "/user/pc/permission/authority/getBindAuthMenuDetail",
    method: "post",
    data,
  });
}

// 获取绑定的权限
export function getBindAuthIdDetail(data) {
  return request({
    url: "/user/pc/permission/role/getBindAuthIdDetail",
    method: "post",
    data,
  });
}

// 用户绑定角色
export function bindURole(data) {
  return request({
    url: "/user/pc/permission/role/bindRoleAuth",
    method: "post",
    data,
  });
}

// 用户绑定角色
export function bindUserRole(data) {
  return request({
    url: "/user/pc/permission/menu/bindUserRole",
    method: "post",
    data,
  });
}


// 根据组织机构id获取所有用户
export function getOrgAllUserAndStatisticsPage(data) {
  return request({
    url: "/user/pc/org/getOrgAllUserAndStatisticsPage",
    method: "post",
    data,
  });
}

// 重置密码
export function resetUserPwd(data) {
  return request({
    url: "/user/pc/org/user/resetUserPwd",
    method: "post",
    data,
  });
}

// 设置用户状态
export function setUserAccount(data) {
  return request({
    url: "/user/pc/org/user/setUserAccountStatus",
    method: "post",
    data,
  });
}


// 新增用户
export function addUserAndJoinOrg(data) {
  return request({
    url: "/user/pc/org/department/addUserAndJoinOrg",
    method: "post",
    data,
  });
}

// 获取角色列表
export function getUserRoleList(data = {}) {
  return request({
    url: "/user/pc/permission/role/list",
    method: "post",
    data,
  });
}

// 获取权限菜单
export function getHaveAuthMenu(data = {}) {
  return request({
    url: "/user/pc/home/myInfo/getHaveAuthMenu",
    method: "post",
    data,
  });
}

// 批量移除用户
export function removeUserList(data = {}) {
  return request({
    url: "/user/pc/org/department/removeUserList",
    method: "post",
    data,
  });
}

// 设置为部门负责人
export function setUserIsPrincipal(data = {}) {
  return request({
    url: "/user/pc/org/department/setUserIsPrincipal",
    method: "post",
    data,
  });
}

// 批量移动
export function moveUserToOtherDepartment(data = {}) {
  return request({
    url: "/user/pc/org/department/moveUserToOtherDepartment",
    method: "post",
    data,
  });
}

// 根据名称获取公司
export function getCompanySelectByCompanyName(data) {
  return request({
    url: "/global/base/getCompanySelectByCompanyName",
    method: "post",
    data,
  });
}